<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>工作人员管理 - 疫苗预约系统</title>
    <link rel="stylesheet" href="../css/common.css?v=20251119">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body>
    <div class="main-container">
        <!-- 侧边栏 -->
        <div class="sidebar">
            <div class="sidebar-header">
                <i class="fas fa-syringe"></i>
                <h2>疫苗预约系统</h2>
                <p>系统管理员</p>
            </div>
            <nav class="sidebar-menu">
                <a href="home.html" class="menu-item">
                    <i class="fas fa-home"></i>
                    <span>首页</span>
                </a>
                <a href="site.html" class="menu-item">
                    <i class="fas fa-hospital"></i>
                    <span>接种点管理</span>
                </a>
                <a href="staff.html" class="menu-item active">
                    <i class="fas fa-user-tie"></i>
                    <span>工作人员管理</span>
                </a>
                <a href="vaccine.html" class="menu-item">
                    <i class="fas fa-vial"></i>
                    <span>疫苗管理</span>
                </a>
                <a href="statistics.html" class="menu-item">
                    <i class="fas fa-chart-line"></i>
                    <span>数据统计</span>
                </a>
            </nav>
        </div>

        <!-- 主内容区域 -->
        <div class="main-content">
            <!-- 顶部导航栏 -->
            <div class="top-navbar">
                <div class="navbar-left">
                    <h1>工作人员管理</h1>
                </div>
                <div class="navbar-right">
                    <div class="user-info">
                        <div class="user-avatar" id="userAvatar">S</div>
                        <span class="user-name" id="userName">超级管理员</span>
                    </div>
                    <button class="btn-logout" onclick="handleLogout()">
                        <i class="fas fa-sign-out-alt"></i> 退出登录
                    </button>
                </div>
            </div>

            <!-- 内容区域 -->
            <div class="content-area">
                <!-- 页面标题 -->
                <div class="page-header">
                    <h2 class="page-title">工作人员管理</h2>
                    <button class="btn btn-primary" onclick="showAddModal()">
                        <i class="fas fa-plus"></i> 创建工作人员
                    </button>
                </div>

                <!-- 筛选条件 -->
                <div class="card">
                    <div class="card-body">
                        <div class="filter-group">
                            <label for="roleFilter">角色筛选：</label>
                            <select id="roleFilter" class="form-control" onchange="handleFilterChange()" style="width: 200px;">
                                <option value="">全部</option>
                                <option value="1">接种点管理员</option>
                                <option value="2">超级管理员</option>
                            </select>
                        </div>
                    </div>
                </div>

                <!-- 工作人员列表 -->
                <div class="card">
                    <div class="card-header">
                        <h3 class="card-title">工作人员列表</h3>
                    </div>
                    <div class="card-body">
                        <div class="table-container">
                            <table class="table">
                                <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>账号</th>
                                        <th>姓名</th>
                                        <th>年龄</th>
                                        <th>身份证号</th>
                                        <th>邮箱</th>
                                        <th>角色</th>
                                        <th>所属接种点</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="staffTableBody">
                                    <tr>
                                        <td colspan="9" class="text-center">加载中...</td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>

                        <!-- 分页 -->
                        <div class="pagination" id="pagination"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 创建工作人员模态框 -->
    <div class="modal" id="staffModal">
        <div class="modal-content" style="max-width: 600px;">
            <div class="modal-header">
                <h3>创建工作人员账号</h3>
                <button class="modal-close" onclick="closeModal()">&times;</button>
            </div>
            <div class="modal-body">
                <form id="staffForm">
                    <div class="form-group">
                        <label for="staffAccount">账号 <span class="required">*</span></label>
                        <input type="text" id="staffAccount" class="form-control" required minlength="4" maxlength="20">
                        <small class="form-text">4-20个字符</small>
                    </div>

                    <div class="form-group">
                        <label for="staffPassword">密码 <span class="required">*</span></label>
                        <input type="password" id="staffPassword" class="form-control" required minlength="6" maxlength="20">
                        <small class="form-text">6-20个字符</small>
                    </div>

                    <div class="form-group">
                        <label for="staffEmail">邮箱</label>
                        <input type="email" id="staffEmail" class="form-control" maxlength="100">
                    </div>

                    <div class="form-group">
                        <label for="staffName">姓名 <span class="required">*</span></label>
                        <input type="text" id="staffName" class="form-control" required maxlength="50">
                    </div>

                    <div class="form-group">
                        <label for="staffAge">年龄 <span class="required">*</span></label>
                        <input type="number" id="staffAge" class="form-control" required min="18" max="100">
                    </div>

                    <div class="form-group">
                        <label for="staffIdNum">身份证号 <span class="required">*</span></label>
                        <input type="text" id="staffIdNum" class="form-control" required pattern="^\d{17}[\dXx]$" maxlength="18">
                        <small class="form-text">18位身份证号码</small>
                    </div>

                    <div class="form-group">
                        <label for="staffRole">角色 <span class="required">*</span></label>
                        <select id="staffRole" class="form-control" required onchange="handleRoleChange()">
                            <option value="">请选择</option>
                            <option value="1">接种点管理员</option>
                            <option value="2">超级管理员</option>
                        </select>
                    </div>

                    <div class="form-group" id="siteSelectGroup" style="display: none;">
                        <label for="staffSiteId">所属接种点 <span class="required">*</span></label>
                        <select id="staffSiteId" class="form-control">
                            <option value="">请选择</option>
                        </select>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button class="btn btn-secondary" onclick="closeModal()">取消</button>
                <button class="btn btn-primary" onclick="handleSubmit()">创建</button>
            </div>
        </div>
    </div>

    <!-- 重置密码模态框 -->
    <div class="modal" id="resetPasswordModal">
        <div class="modal-content" style="max-width: 400px;">
            <div class="modal-header">
                <h3>重置密码</h3>
                <button class="modal-close" onclick="closeResetPasswordModal()">&times;</button>
            </div>
            <div class="modal-body">
                <form id="resetPasswordForm">
                    <input type="hidden" id="resetStaffId">
                    <div class="form-group">
                        <label for="newPassword">新密码 <span class="required">*</span></label>
                        <input type="password" id="newPassword" class="form-control" required minlength="6" maxlength="20">
                        <small class="form-text">6-20个字符</small>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button class="btn btn-secondary" onclick="closeResetPasswordModal()">取消</button>
                <button class="btn btn-primary" onclick="handleResetPassword()">确定</button>
            </div>
        </div>
    </div>

    <script src="../js/common.js"></script>
    <script src="js/staff.js"></script>
</body>
</html>

